package mrirnaproject;
import java.io.File;     
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

import org.biojava3.core.sequence.DNASequence;
import org.biojava3.core.sequence.RNASequence;

public class InputFiles {
	
	public String RefFile() {
	
		
	
	Scanner sc = new Scanner(System.in);
	String subPattern = "";
	Scanner input = null;
	
	System.out.println("Input path of Reference file:");

	
	
	boolean isFile = false;
	
	
	while (isFile == false){    

	    String fileName = sc.next();
	    File inputFile = new File(fileName);

	    if (inputFile.exists()){
	        try {
				input = new Scanner(inputFile);
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	        isFile = true;
	    }            
	    char c = input.next().charAt(0);
	  
	if(c == '>'){
		
		input.nextLine();
	    while(input.hasNextLine()){
	    subPattern = subPattern + input.nextLine();
	    }
	    }
	
	    else {
	    	 while(input.hasNextLine()){
	    		    subPattern = subPattern + input.nextLine();
	    	 }
	    		    }
	    }
	    

              input.close();
             

	System.out.println("Subpattern: " + subPattern);
	

	
	DNASequence DNAfile = new DNASequence(subPattern);
	RNASequence RNAfile = DNAfile.getRNASequence();
	System.out.println(RNAfile.toString());
	System.out.println("Input path of miRNA file:");

	
	
	 Scanner input_again = null;
	 
       String miRNA = null;

       boolean isFile2 = false;
   	
   	
   	while (isFile2 == false){    

   	    String fileName2 =sc.next();
   	    File inputFile2 = new File(fileName2);

   	    if (inputFile2.exists()){
   	        try {
   				input_again = new Scanner(inputFile2);
   			} catch (FileNotFoundException e) {
   				// TODO Auto-generated catch block
   				e.printStackTrace();
   			}
   	        isFile2 = true;
   	    }
   	}
       
    Queue<String> myQ = new LinkedList<String>();
   	
   	
   	/*List<String> list = new ArrayList<String>();*/
       while(input_again.hasNextLine()){
		   miRNA = input_again.nextLine();
    	   myQ.add(miRNA);
    	   myQ.remove("");
		} 
		
		
       input_again.close();
       sc.close();
	String[] stringArr = myQ.toArray(new String[0]);
      	       return Arrays.toString(stringArr);
		
				
	
	} 

	
}

